//
// Created by Soar Qin on 2017/8/22.
// Copyright (c) 2017 Soar Qin. All rights reserved.
//

#pragma once

#include "io_base.hh"

namespace core::async {

struct TcpListenerContext;
class IPAddr;
class TCPEndpoint;

class TCPListener: public IoBase {
    DISABLE_CLASS_COPY(TCPListener);
public:
    explicit TCPListener(Loop &loop);
    virtual ~TCPListener();

    bool listen(const IPAddr &addr);
    bool listen(const std::string &address);
    bool listen(const std::string &ip, uint16_t port);

    virtual bool onAccept(int fd) = 0;

protected:
    TcpListenerContext *context_;
};

}
